import axios from 'axios';
import store from '@/store';

//自定义配置创建axios的新实例
const service=axios.create({
   baseURL:'/api/index.php/index/wxapp.login/',
   withCredentials: true,
   timeout:50000
}) 

// 请求拦截器,发起请求,打开loading
   service.interceptors.request.use(
   config => {
      if(store.state.token){
        console.log(111)  
        config.headers.token=store.state.token;
      }
          return config;
      }, err => {
          return Promise.reject(err)
   
   })
//响应拦截器,响应回来关闭loading
   service.interceptors.response.use(
   response => {
      return response; 
   }, err => {
        return Promise.reject(err);
   })
 
export default service; 